#include "../Header Files/CUnit.h"


bool CUnit::TakeDamage(int dmg)
{
	//reduce the incoming damage by the defense stat.
	dmg -= m_nDefense;
	//if the incoming damage has been nullified, leave the function.
	if (dmg <= 0)
		return true;
	//reduce the current hitpoints by the incomming damage.
	m_nCurHitPoints -= dmg;
	//if the target has died, return false (with the additional logic that if the
	//unit took so much damage it overloaded the INT variable to a positive number.
	if (m_nCurHitPoints <= 0 || m_nCurHitPoints >= m_nMaxHitpoints)
	{
		return false;
	}
	//The unit must have lived through it if we've gotten down here, return true
	return true;
}